//
//  LXExtension+UINavigationBar.swift
//  LXExtensions
//
//  Created by yoctech on 2021/8/11.
//

import Foundation

@objc public extension UINavigationBar {
    @objc func lx_shadowColor(_ color: UIColor, height:CGFloat = 0.5) {
        self.shadowImage = UIImage.lx_with(color: color, size: CGSize(width: self.lx_width, height: height))
    }
    
    @objc func lx_color(tint: UIColor, barTint: UIColor, shadow: UIColor, isTranslucent: Bool = false) {
        self.tintColor = tint
        self.barTintColor = barTint
        self.lx_shadowColor(shadow)
        self.isTranslucent = isTranslucent
    }
    @objc func lx_title(font: UIFont, color: UIColor) {
        self.titleTextAttributes = [
            NSAttributedString.Key.foregroundColor: color,
            NSAttributedString.Key.font: font]
    }
    @objc func lx_hideBackTitle() {
        if #available(iOS 14.0, *) {
            self.backItem?.backButtonDisplayMode = .minimal
        } else if #available(iOS 11.0, *) {
            self.backItem?.backButtonTitle = nil
        } else {
            self.backItem?.backBarButtonItem?.setBackButtonTitlePositionAdjustment(.init(horizontal: 0, vertical: -60), for: .default)
        }
    }
}
